Sparse Representations for Text Classification

ABSTRACT

A sparse representation method of text classification is described. An input text document is represented as a document feature vector y. A category dictionary H provides possible examples [h 1 ; h 2 ; . . . ; h n ] of the document feature vector y. The input text document is classified using a sparse representation text classification algorithm that solves for y=Hβ where a sparseness condition is enforced on β to select a small number of examples from the dictionary H to describe the document feature vector y.

This application claims priority from U.S. Provisional Patent Application 61/386,015, filed Sep. 24, 2010; which is incorporated herein by reference.

TECHNICAL FIELD

The present invention relates to text classification in Natural Language Processing (NLP) applications.

BACKGROUND ART

Text classification, with a spectrum of applications in Natural Language Processing (NLP) that range from document categorization to information retrieval, is the problem of classifying text documents into topics or pre-defined sets of classes. There has been a tremendous amount of work done on text classification, including techniques based on decision trees, neural networks, nearest neighbor methods, Rocchios method, support vector machines (SVM), linear least squares, Naive Bayes, rule-based methods and more. Some of these methods are unsupervised (no labeled documents—see, e.g., Y. Ko and J. Seo, Automatic Text Categorization by Unsupervised Learning, In Proceedings of COLING-00, the 18^(th) International Conference on Computational Linguistics, incorporated herein by reference) while most of the methods assume a set of document or topic labels (see, e.g., Dasgupta et al., Feature Selection Methods For Text Classification, in Proceedings of the 13th Annual ACM SIGKDD Conference, 2007, pp. 230-239; T. Joachims, Text Categorization With Support Vector Machines: Learning With Many Relevant Features, ECML, 1998; A. McCallum and K. Nigam, A Comparison Of Event Models For Naive Bayes Text Classification, in Proc. of the AAAI-98 Workshop on Learning for Text Classification, AAAI Press, 1998, pp. 41-48; incorporated herein by reference).

McCallum and Nigam showed that even a simple supervised classifier can produce acceptable classification accuracy. They showed that text could be classified by assuming conditional independence between words given the labels and by building a Naive Bayes Classifier. The test document can be classified simply by computing the likelihood of the class label given the words of the document based on Bayes' theorem. Although such a trivial method produced promising results, text classification was further improved by Joachims who presented an SVM-based classifier to classify documents which showed that a more sophisticated algorithm can classify documents better than a simple Naive Bayes approach. Since Joachims work, many more supervised algorithms have been proposed for text classification which are described in detail in E. Sebastiani, Machine Learning In Automated Text Categorization, CoRR, vol. cs.IR/0110053, 2001, incorporated herein by reference.

In a conventional Naïve Bayes (NB) classification approach, given a test document feature vector y, the a posterior probability for class C_(i) given y is defined as:

${p\left( C_{i} \middle| y \right)} = \frac{{p\left( C_{i} \right)}{p\left( y \middle| C_{i} \right)}}{p(y)}$

Within the NB framework, the best class is defined as the one which maximizes the posterior probability. In other words,

$i^{*} = {\max\limits_{i}{p\left( C_{i} \middle| y \right)}}$

where the terms p(C_(i)) and p(y|C_(i)) can be estimated as described below, and where the term p(y) can be assumed to be constant across different classes and so typically is ignored.

The prior probability of class C_(i) is p(C_(i)), which can be computed on the training set by counting the number of occurrences of each class. In other words if N is the total number of documents in training and N, is the number of documents from class i, then

${P\left( C_{i} \right)} = {\frac{N_{i}}{N}.}$

The term p(y|C_(i)) can be computed assuming that document y is comprised of the words y={w₁, w₂, . . . , w_(n)}, where n is the number of words. A “naive” conditional independence assumption is made on the term p(y|C_(i))=p(w₁, . . . w_(n|)C_(i)) and it is expressed as:

${P\left( {w_{1},\left. {\ldots \mspace{14mu} w_{n}} \middle| C_{i} \right.} \right)} = {\prod\limits_{j = 1}^{n}{P\left( w_{j} \middle| C_{i} \right)}}$

Each term P(w_(j)|C_(i)) is computed by counting the number of times word w_(j) appears in the training documents from class C_(i). Typically to avoid non-zero probabilities if word w_(j), is not found in class C_(i), add-one smoothing is used. Thus if we define N_(ij) as the number of times word w_(j) is not found in class C_(i), we define P(w_(j)|C_(i)) as follows, where V is the size of the vocabulary:

${P\left( w_{j} \middle| C_{i} \right)} = \frac{N_{ij} + 1}{{\sum_{i}N_{ij}} + V}$

The above equations show that instead of making a classification decision on a test document using information about individual examples in training, the Naive Bayes method pools all information about training data to estimate probability models for P(C_(i)) and P(w_(j)|C_(i)).

Besides the improvement in the types of classifiers there has been significant work in feature selection for text classification. Some of these feature selection methods are based on information gain, odd ratio, F-measure and Chi-Square testing (see, e.g., Ko and Seo; F. George, An Extensive Empirical Study Of Feature Selection Metrics For Text Classification, Journal of Machine Learning Research, vol. 3, pp. 1289-1305, 2003; incorporated herein by reference). Although the type of feature selection algorithm may vary, it is agreed that feature selection is crucial and improves the performance of a text classifier.

SUMMARY

Embodiments of the present invention are directed to using sparse representations (SRs) for text classification. SRs have been used in other signal processing applications to characterize a test signal using just a few support training examples and allow the number of supports to be adapted to the specific signal being classified. SRs have demonstrated good performance compared to other classifiers for both image classification and phonetic classification, and we extend their use for text classification where their performance varies with the vocabulary size of the documents. SRs provide an alternative class of methods for text classification and offer promising performance compared to standard classifiers used for text classification such as a Naive Bayes (NB) classifier.

In a typical embodiment of the present invention, an input text document is represented as a document feature vector y. A category dictionary H provides possible examples [h₁; h₂; . . . ; h_(n)] of the document feature vector y. The input text document is classified using a sparse representation text classification approach to solve for y=Hβ and enforcing a sparseness condition on β to select a small number of examples from the dictionary H to describe the document feature vector y.

In further specific embodiments, β may be determined by Approximate Bayesian Compressive Sensing (ABCS). The text classification algorithm may use a maximum support classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has largest support in β. Or the text classification algorithm may use a maximum l₂ classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has largest l₂ norm based on a selector δi (β)ε

^(m) to compute an 1₂ norm for β for a class i as ∥δ(β)∥₂. Or the text classification algorithm may use a residual error classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has a smallest residual error based on a selector δi(β)ε

^(m) to compute a residual error for β a for a class i as ∥y−Hδi (β)∥₂.

Embodiments also include a text classification engine implemented as one or more computer processes functioning in a computer processor and using a method according to any of the above. Embodiments also include a computer program product for text classification implemented in a tangible computer readable storage medium which includes program code for performing a method according to any of the above.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows an exemplary embodiment of the present invention for text classification based on Sparse Representation (SR).

FIG. 2 shows the β coefficients for a randomly sampled test document y.

FIG. 3 shows the accuracies of two types of text classifiers for varied vocabulary size.

DETAILED DESCRIPTION

In contrast to the Naïve Bayes method for classification, an exemplar-based representation method can be used for text classification based on a Sparse Representation (SR) approach. The motivation for using SRs for text classification is two fold. First, SRs have been successful for face recognition (J. Wright, A. Yang, A. Ganesh, S. S. Sastry, and Y. Ma, Robust Face Recognition via Sparse Representation, IEEE Trans. on Pattern Analysis and Machine Intelligence, vol. 31, pp. 210-227, 2009 (incorporated herein by reference) and phonetic classification (T. N. Sainath, A. Carmi, D. Kanevsky, and B. Ramabhadran, Bayesian Compressive Sensing for Phonetic Classification, in Proc. ICASSP, 2010, incorporated herein by reference). SRs have been shown to offer improvements over other well-known classification schemes including Gaussian Mixture Model (GMM), Support Vector Machine (SVM) and k-nearest neighbor (kNN) algorithms. Second, SRs adaptively select the relevant support data points from the training data, allowing discriminative classification of the text document with just a few relevant examples of the document corpus.

In formal mathematical terms, in a typical SR formulation a dictionary H is constructed consisting of possible examples of the signal, that is H=[h₁; h₂; . . . ; h_(n)], where each h_(i)εRe^(m). H is an over-complete dictionary such that the number of examples n is much greater than the dimension of each h_(i) (i.e. m<<N). To reconstruct a signal y from H, SR solves the equation y=Hβ. A sparseness condition is enforced on β such that it selects a small number of examples from H to describe y. In contrast to Sainath et al. above where only a subset of training examples was selected to seed H, it may be useful to seed the dictionary H using all training documents. This makes the size of H much larger and also enforces a stronger need for sparseness on β.

FIG. 1 shows an exemplary embodiment of the present invention having a text input module 101 document that represents an unclassified input text as a document feature vector y. A category dictionary H 102 provides possible examples [h₁; h₂; . . . ; h_(n)] of the document feature vector y. Text categorizer 103 classifies the input text document using a sparse representation algorithm 104 to solve for y=H/β and enforcing a sparseness condition on β to select a small number of examples from the dictionary H to describe the document feature vector y, thereby producing a classified output text.

The goal of text classification is to use training data from k different classes to determine the best class to assign to test document feature vector y. Initially consider taking all training examples n_(i) from class i and concatenate them into a matrix H_(i) as columns. In other words, H_(i)=[x_(i,1), x_(i,2), . . . , x_(i,ni)]ε

^(mxn) ^(i) , where xε

^(m) represents the feature vector of a document from the training set from class i with dimension m. For example, one can think of each x as a term-frequency feature where the dimension m corresponds to the size of the vocabulary. Wright et al. shows that given sufficient training examples from class i, a test sample y from the same class can be represented as a linear combination of the entries in H_(i) weighted by β. That is:

y=β _(i,1) x _(i,1)+β_(i,2) x _(i,2)+ . . . +β_(i,n) _(i) x _(i,n) _(i)

However, since the class membership of y is unknown, a matrix His defined to include training examples from all k classes in the training set. In other words, the columns of H are defined as H=[H₁H₂, . . . , H_(k)]=[x_(l,1), x_(l,2), . . . , x_(k,nk)]ε

^(mxn) ^(i) . Here m is the dimension of each feature vector x, and N is the total number of all training examples from all classes. H can be thought of as an over-complete dictionary where m<<N. The test vector y can now be written as a linear combination of all training examples: y=Hβ. Ideally the optimal β should be sparse and only be non-zero since the elements in H will belong to the same class as y. Thus ideally, y will assign itself to lie in the linear span of examples from the training set of the true class it belongs to.

The following discussion solves the problem y=H subject to a sparseness constraint on β. As Wright discusses, the sparseness constraint on β acts as a regularization term to prevent over-fitting and reduce sensitivity to outliers, and often allows for better classification performance than without sparseness. This is particularly significant when m <<N as explained below. Various specific sparse representation methods can be used to solve the above problem. For example, β can be determined by Approximate Bayesian Compressive Sensing (ABCS) (see, e.g., T. N. Sainath, A. Carmi, D. Kanevsky, and B. Ramabhadran, Bayesian Compressive Sensing for Phonetic Classification, in Proc. ICASSP, 2010, incorporated herein by reference) which imposes a combination of an l₁ and 1₂ norm on β.

Having discussed how to solve for β, we now can discuss how to assign y as belonging to a specific class. Various classification rules are available such as maximum support, maximum l₂ support, and residual error rules. For example, using a maximum support rule, all nonzero entries of β ideally should correspond to the entries in H with the same class as y. In this ideal case, y will assign itself to one training example from H and y can be assigned to the class which has the largest support in β:

$i^{*} = {\max\limits_{i}(\beta)}$

However due to noise and modeling error, β belonging to other classes could potentially be non-zero. Therefore, a maximum l₂ classification rule can be used to compute the 1₂ norm for all β entries within a specific class, and choose the class with the largest 1₂ norm support. More specifically, a selector δ_(i)(β)ε

^(m) can be defined as a vector whose entries are non-zero except for entries in β corresponding to class i. The 1₂ norm for β for class i can then be computed as ∥δ_(i)(β)∥₂. The best class for y will be the class in β with the largest 1₂ norm. Mathematically, the best class i* is defined as:

$i^{*} = {\max\limits_{i}{{\delta_{i}(\beta)}}_{2}}$

As Wright discusses, a classification decision can also be formulated by measuring how well y assigns itself to different classes in H. This can be thought of as looking at the residual error between y and the H/β entries corresponding to a specific class. A selector δ_(i)(β)δ

^(m) can be defined as a vector whose entries are non-zero except for entries in β corresponding to class i. The residual error for class i can then be computed as ∥y−Hδ_(i) (β)₂ and the best class for y will be the class with the smallest residual error. Mathematically, the best class i* is defined as:

$i^{*} = {\min\limits_{i}{{y - {H\; {\delta_{i}(\beta)}}}}_{2}}$

Various experiments have been performed to explore these concepts for text classification using the 20 Newsgroup corpus which consists of 20,000 newsgroup documents that are divided into 20 different classes. 40% of the documents were separated as a held-out test set (roughly 7,532) while the remaining 60% (rough 11,314) were used for training the models. These text documents are quite noisy, for example, email addresses in the headers an hyperlinks and email addresses in the text body.

Various kinds of features have been explored for text classification. For example, the Term Frequency (TF) feature can provide important information about the word distribution relevant for the class label of the document. For example, documents that are labeled as “Hockey” may contain words such as “hockey” and “puck” in higher frequency than words that are related to other sports. Here TF is defined by:

TF=Σ n _(i)

where n_(i) is the number of times the i^(th) term occurred in document d.

Typically TF features are often weighted by Inverse Document Frequency (IDF) features which provides even better discriminating property among different classes of documents. However, it has been shown that for the 20 Newsgroup Corpus, using the TF features provides better accuracy than using TF features weighted by the IDF counts. After extracting TF features for all the words in a document, each document was represented with a TF vector of length |V| that is equal to the vocabulary size of the whole corpus, which is 55,710. The experimental embodiment of the SR method needed the number of documents in H(11,314) to be less than the dimension of each TF feature vector (i.e. |V|), so pruning the vocabulary size of TF vectors was explored. This pruning was accomplished by removing words from the vocabulary if the total number of occurrences in training was less than a certain frequency threshold. The NB and SR classifiers we analyzed varying the vocabulary size of the TF vectors from 1,000 to 10,000 in increments of 1,000.

One set of experiments explored the behavior of the β coefficients obtained by solving y=Hβ using ABCS. FIG. 1 shows the β coefficients for a randomly sampled test document y. The 1,400 β coefficients corresponding to 1,400 training document in H were obtained by picking every 8^(th)β coefficient from the full set of 11,314 training documents. FIG. 1 shows that the β entries are quite sparse, suggesting that with the SR technique, only a few samples in H are used to characterize y. For example, roughly only 1% of the absolute value of the β coefficients are 0.035. As Wright discusses, this sparsity can be thought of as a form of discrimination where certain documents in H are selected as “good,” while jointly assigning zero weights to “bad” documents in H.

The effect of sparseness can be further analyzed by looking at the classification accuracy by solving y=Hβ when enforcing a sparseness on β versus no sparseness. Table 1 compares the results for the two approaches for a vocabulary size of 6,215:

TABLE 1 Classification Accuracy with and Without Sparseness Constraint on β Method Accuracy No Sparseness Constraint 78.8 Sparseness Constraint 78.6 A classification metric defined by a maximum l₂ support rule as discussed above. Table 1 shows that enforcing sparseness, and therefore utilizing only a small fraction of examples, provides at least a small improvement in accuracy.

A set of experiments also explored the accuracy with different sparse representation classification metrics. Table 2 shows these accuracies for a vocabulary size of 6,215 and also shows the NB accuracy as a comparison:

TABLE 2 Classification Accuracy for Different Sparse Representation Decisions Classification Decision Accuracy NB 77.9 Maximum Support 77.2 Maximum l₂ Support 78.8 Minimum Residual Error 55.5

Notice that using Maximum Support as a metric was too hard a decision, as β from other classes was often non-zero. Therefore, making a softer decision by using the l₂ norm of β offered higher accuracy. In addition, using the residual error offered the lowest accuracy. Because the features are so sparse, the residual value of μy−Hδ_(i) (β)∥₂ when δ_(i)(β)≈0 will reduce to ∥y∥₂, which is a very small number and might not offer good distinguishability from class residuals in which δ_(i)(β) is high. Thus, in the remainder of the experiments, the l₂ norm of β was used to make classification decisions.

The behavior of SR and NB methods also was experimentally explored as the vocabulary size was varied from 1,000 to 10,000. FIG. 2 shows the accuracies of the two types of text classifiers for varied vocabulary size. FIG. 2 shows that accuracy of both classifiers increased as the vocabulary size increased. The larger vocabulary size allowed more features to be used in discriminating the documents across different classes. Between a vocabulary size of 1,000 and 8,000, the sparse representation method offered between a 0.3-0.8% absolute improvement compared to NB, and a McNemar's significance test also confirmed that this difference was statistically significant. When the vocabulary size increased beyond 8,000, the accuracy of the SR method dropped and approached that of the NB method. This can be attributed to the behavior of the SR technique which requires that the number of training documents N be much less than the vocabulary size m. As m approaches N, the SR method has less freedom to choose β since there are more systems of equations to solve when computing y=Hβ. Thus sparsity becomes less beneficial and the SR accuracy approaches that of a non-sparse solution which as explained above was slightly lower than the SR accuracy when sparsity can be applied. The accuracy of the SR and NB methods above 10,000 was not compared because this would make the SR ineffective since m>N. However, it has been observed that the accuracy does not improve significantly when the vocabulary size is greater than 10,000.

The foregoing indicates that sparse representations can be used in Natural Language Processing (NLP) tasks such as text classification. Experimental results show that an SR method offers some improvements over a standard Naive Bayes (NB) classifier across varying vocabulary sizes. Though the tested SR method may not have performed better than state of the art text classification techniques, the preliminary results show that SRs can be effectively used for text classification. In other settings, SRs may be more useful for text classification with better feature selection techniques. SRs may also be considered and compared to Support Vector Machines (SVMs) as has been done for phonetic classification.

Embodiments of the invention may be implemented in whole or in part in any conventional computer programming language. For example, preferred embodiments may be implemented in a procedural programming language (e.g., “C”) or an object oriented programming language (e.g., “C++”, Python). Alternative embodiments of the invention may be implemented as pre-programmed hardware elements, other related components, or as a combination of hardware and software components.

Embodiments can be implemented in whole or in part as a computer program product for use with a computer system. Such implementation may include a series of computer instructions fixed either on a tangible medium, such as a computer readable medium (e.g., a diskette, CD-ROM, ROM, or fixed disk) or transmittable to a computer system, via a modem or other interface device, such as a communications adapter connected to a network over a medium. The medium may be either a tangible medium (e.g., optical or analog communications lines) or a medium implemented with wireless techniques (e.g., microwave, infrared or other transmission techniques). The series of computer instructions embodies all or part of the functionality previously described herein with respect to the system. Those skilled in the art should appreciate that such computer instructions can be written in a number of programming languages for use with many computer architectures or operating systems. Furthermore, such instructions may be stored in any memory device, such as semiconductor, magnetic, optical or other memory devices, and may be transmitted using any communications technology, such as optical, infrared, microwave, or other transmission technologies. It is expected that such a computer program product may be distributed as a removable medium with accompanying printed or electronic documentation (e.g., shrink wrapped software), preloaded with a computer system (e.g., on system ROM or fixed disk), or distributed from a server or electronic bulletin board over the network (e.g., the Internet or World Wide Web). Of course, some embodiments of the invention may be implemented as a combination of both software (e.g., a computer program product) and hardware. Still other embodiments of the invention are implemented as entirely hardware, or entirely software (e.g., a computer program product).

Although various exemplary embodiments of the invention have been disclosed; it should be apparent to those skilled in the art that various changes and modifications can be made which will achieve some of the advantages of the invention without departing from the true scope of the invention. 

1. A sparse representation-based text classification engine employing at least one hardware implemented computer processor and comprising: a text input module that receives an input text document and represents it as a document feature vector y; a category dictionary H of possible examples [h₁; h₂; . . . ; h_(n)] of the document feature vector y; and a text classifier that receives the document feature vector y and accesses the category dictionary H to automatically classify the input text document based on a sparse representation text classification approach to solve for y=Hβ and enforcing a sparseness condition β to select examples from the dictionary H to describe the document feature vector y.
 2. A text classification engine according to claim 1, wherein the text classifier determines β by Approximate Bayesian Compressive Sensing (ABCS).
 3. A text classification engine according to claim 1, wherein the text classifier uses a maximum support classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has largest support in β.
 4. A text classification engine according to claim 1, wherein the text classifier uses a maximum l₂ classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has largest l₂ norm based on a selector δi (β)ε

^(m) to compute an 1₂ norm for β for a class i as ∥δi (β)∥₂.
 5. A text classification engine according to claim 1, wherein the text classifier uses a residual error classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has a smallest residual error based on a selector δi (β)ε

^(m) to compute a residual error for β for a class i as ∥y−Hδ_(i) (β)∥₂.
 6. A computer-implemented method of text classification based on sparse representation employing at least one hardware implemented computer processor, the method comprising: representing in a computer process an input text document as a document feature vector y; accessing in a computer process a category dictionary H of possible examples [h₁; h₂; . . . ; h_(n)] of the document feature vector y; and automatically classifying in a computer process the input text document based on a sparse representation text classification approach to solve for y=Hβ and enforcing a sparseness condition β to select examples from the dictionary H to describe the document feature vector y.
 7. A method according to claim 6, wherein β is determined by Approximate Bayesian Compressive Sensing (ABCS).
 8. A method according to claim 6, wherein the text classification approach uses a maximum support classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has largest support in β.
 9. A method according to claim 6, wherein the text classification approach uses a maximum l₂ classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has largest l₂ norm based on a selector δi (β)ε

^(m) to compute an 1₂ norm for β for a class i as ∥δi (β)∥₂.
 10. A method according to claim 6, wherein the text classification approach uses a residual error classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has a smallest residual error based on a selector δi (β)ε

^(m) to compute a residual error for β for a class i as ∥y−Hδ_(i) (β)∥₂.
 11. A computer program product for text classification implemented in a tangible computer readable storage medium, the product comprising: program code for representing an input text document as a document feature vector y; program code for accessing a category dictionary H of possible examples [h₁; h₂; . . . ; h_(n)] of the document feature vector y; and program code for automatically classifying the input text document based on a sparse representation text classification approach to solve for y=Hβ and enforcing a sparseness condition β to select examples from the dictionary H to describe the document feature vector y.
 12. A product according to claim 11, wherein β is determined by Approximate Bayesian Compressive Sensing (ABCS).
 13. A product according to claim 11, wherein the text classification approach uses a maximum support classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has largest support in β.
 14. A product according to claim 11, wherein the text classification approach uses a maximum l₂ classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has largest l₂ norm based on a selector δi (β)ε

^(m) to compute an 1₂ norm for β for a class i as ∥δi (β)∥₂.
 15. A product according to claim 11, wherein the text classification approach uses a residual error classification rule that assigns the document feature vector y to a best class i* within the category dictionary H which has a smallest residual error based on a selector δi (β)ε

^(m) to compute a residual error for β for a class i as ∥y−Hδ_(i) (β)∥_(2.) 